/* eslint-disable */
<template>
  <div id="app">
    <img alt="Vue logo" src="./assets/logo.png">
    <button @click="changeParent">gaib</button>
    <div>{{ obj.name }}</div>
    <HelloWorld msg="Welcome to Your Vue.js App" :getMsg="getMsg" :test="obj"/>
    <myTree />
    <div>
      <input type="text" v-model="name">
      <button @click="add">添加</button>
    </div>
    <ul>
      <li v-for="item in list">
        <input type="checkbox"> {{ item.name }}
      </li>
    </ul>
    <router-link to="/home">首页</router-link>
    <router-link to="/about">关于</router-link>
    <router-view></router-view>
  </div>

</template>

<script>

import HelloWorld from './components/HelloWorld.vue'
import myTree from './components/MyTree.vue'
import zz from './module/b.js'
import zzy from './module/c.js'

export default {
  name: 'App',
  data() {
    return {
      msg: '我是父组件的m,sg',
      obj: {
        name: 'parent'
      },
      name: '',
      newId: 3,
      list: [
        { id: 1, name: '李斯' },
        { id: 2, name: '吕不韦' },
        { id: 3, name: '嬴政' }
      ]
    }
  },
  watch: {
    msg(oldVal, newVal) {
      console.log('触发', oldVal, newVal);
    }
  },
  components: {
    HelloWorld,
    myTree
  },
  methods: {
    add() {
      //注意这里是unshift
      // this.list.unshift({ id: ++this.newId, name: this.name })
      // this.name = ''
      console.log('99999');
      this.msg = '我是父组件的m,s'
    },
    getMsg() {
      this.$eventbus.$on('child', () => {
        console.log('000');
      })
      console.log(this.msg);
    },
    changeParent() {
      this.obj.name = '我是父组件ovj'
      this.msg = '父组件改变了'
    }
  },
  provide() {
    return {
      appMsg: () => this.msg,
      obj: this.obj
    }
  }
}
</script>

<style scoped>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
